
import { Select } from 'antd';
import { useTranslation } from 'react-i18next';

function I18() {
     const { t, i18n } = useTranslation();
    const handleChange = (value: string) => {
        console.log(`selected ${value}`);
        i18n.changeLanguage(value)
       localStorage.setItem('lng',value)
    };
    return (
        <div>
            <Select
                defaultValue={localStorage.getItem('lng')}
                style={{ width: 120 }}
                onChange={handleChange}
                options={[
                    { value: 'en', label: '英文' },
                    { value: 'zh', label: '中文' },
                  
                ]}
            />
            <h1>姓名：{t("name")}</h1>
            <h1>年龄：{t("age")}</h1>
            <h1>国家：{t("China")}</h1>
        </div>
    )
}

export default I18
